
package OT.shoufouni.mainGUI;

import OT.shoufouni.serverThreads.serverLogoutQuaryThread;
import OT.shoufouni.serverThreads.serviceUpdateMyLocation;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;

public class options extends Activity {
	Button		logOutButton ;
	Button		aboutButton ;
		
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		
		setContentView(OT.shoufouni.R.layout.options);
		logOutButton 	= (Button)findViewById(OT.shoufouni.R.id.button_exit);
		aboutButton 	= (Button)findViewById(OT.shoufouni.R.id.button_about);
		
		logOutButton.setOnClickListener(new View.OnClickListener() {
		    public void onClick(View view) {
				
				Context context = getApplicationContext();
				SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		        String IdMail = prefs.getString("ID_MAIL", "");
		        
				// logout and stop location's service
		        serverLogoutQuaryThread quaryThread = 
		        	  new serverLogoutQuaryThread( IdMail);
			    quaryThread.start();
			    
			    stopService(new Intent(options.this,serviceUpdateMyLocation.class));
			    
			    Intent intent = new Intent();
				setResult(RESULT_CANCELED,intent);
				finish();
			}
		});
		
		aboutButton.setOnClickListener(new View.OnClickListener() {
		    public void onClick(View view) {
		    	new AlertDialog.Builder(options.this)
		    	.setTitle("About")
		    	.setMessage("SOUFOUNI! ver.01\n\nCreators;\nTomer Priel\nOri Abramovsky")
		    	       .setCancelable(false)
		    	       .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
		    	           public void onClick(DialogInterface dialog, int id) {
		    	        	   dialog.cancel();
		    	           }
		    	       })
		    	.show();
			}
		});	
	}
}

